import axios from 'axios'
import router from "@/router";

export function option(val){
    const t = JSON.parse(localStorage.getItem('syhyDocManSys'))
    let server = axios.create({
        baseURL: 'http://127.0.0.1:8000/',
        // baseURL: 'http://124.70.39.154:8088',
    })

    //取消请求的令牌
    let source = axios.CancelToken.source()



    // 添加响应拦截器
    server.interceptors.response.use(function (res) {
        // 2xx 范围内的状态码都会触发该函数。
        // 对响应数据做点什么
        // console.log(res)
        if(res.data.code === 501 || res.data.code === 500){
            router.push('/login')
        }
        return res;
    }, function (error) {
        // 超出 2xx 范围的状态码都会触发该函数。
        // 对响应错误做点什么
        // alert('未知错误,请联系管理员')
        // console.log(error,'e')
        // location.reload()
        // return Promise.reject(error);
    });

    return server(val)
}


export let baseurl = 'http://127.0.0.1:8000'
// export let baseurl = 'http://124.70.39.154:8088/'
export let previewYRL = 'http://localhost:8080'
// export let previewYRL = 'http://124.70.39.154:8085'
export let resubmitURL = 'http://127.0.0.1:8000/approve/resubmit'
// export let resubmitURL = 'http://124.70.39.154:8088/approve/resubmit'
export let createURL = 'http://127.0.0.1:8000/approve/create'
// export let createURL = 'http://124.70.39.154:8088/approve/create'

export let previewURL = 'http://localhost:8080'
// export let previewURL = 'http://124.70.39.154:8085'
//
